package top.healthylife.gateway.platform.anxinsign.basedto;

import lombok.Data;
import lombok.experimental.Accessors;
import top.healthylife.gateway.dto.request.req.ApiReqDto;

@Data
@Accessors
public abstract class TxBaseRequest extends ApiReqDto {
    public static final String DEFAULT_CHARSET = "UTF-8";
    /**
     * 接口ID
     */
    protected String txCode;
    /**
     * 请求明文
     */
    protected String requestPlainText;
    /**
     * 请求Message
     */
    protected String requestMessage;
    /**
     * 请求签名
     */
    protected String requestSignature;
    /**
     * requestDgtlEnvlp
     */
    protected String requestDgtlEnvlp;
    /**
     * 请求加密SN
     */
    protected String requestSignSN;
    /**
     * 请求加密SN
     */
    protected String requestEncryptSN;
    /**
     * 交易流水号  27位
     */
    protected String txSN ;

    //@SneakyThrows
    //public TxBaseRequest()  {
    //    txSN = GUIDGenerator.genGUID();
    //}
    //
    //
    //public abstract void process() throws Exception;
    //
    //protected void postProcess(String document) throws Exception {
    //    EncryptAndDecrypt encryptAndDecrypt = EncryptAndDecrypt.getEncryptAndDecrypt();
    //    if (encryptAndDecrypt == null) {
    //        throw new Exception("证书未初始化");
    //    } else {
    //        byte[] data = document.getBytes("UTF-8");
    //        String randomKeyData = EncryptAndDecrypt.randomHexString(32);
    //        byte[] randomKey = randomKeyData.getBytes("UTF-8");
    //        this.requestDgtlEnvlp = encryptAndDecrypt.encryptByRSA(randomKey);
    //        this.requestMessage = EncryptAndDecrypt.encode(document, randomKeyData);
    //        this.requestSignature = EncryptAndDecrypt.bytes2hex(encryptAndDecrypt.sign(data));
    //        this.requestPlainText = document;
    //        this.requestSignSN = encryptAndDecrypt.requestSignSN;
    //        this.requestEncryptSN = encryptAndDecrypt.requestEncryptSN;
    //    }
    //}
}
